<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%
	String errorID= request.getParameter("error");
	String errorString = "";
	if(errorID!=null && errorID.equals("1"))
		errorString += "<ul><li>Password do not match.</li></ul> \n\n";
	
	if(errorID!=null && errorID.equals("2"))
			errorString += "<ul><li>This username has already been taken. <br />Please specify a different username.</li></ul> \n\n";
	
		String username = "";
		String password1 = "";
		String password2 = "";
		String country ="";
		
		String first_name = "";
		String last_name = "";
		String email = "";
		String phone = "";
		
		String address ="";
		String city = "";
		String state = "";
		String zipcode = "";
		
	if(request.getParameter("username")!=null)	
	 	username = request.getParameter("username");
	
	if(request.getParameter("password1")!=null)
	 password1 = request.getParameter("password1");

	if(request.getParameter("password2")!=null)
		 password2 = request.getParameter("password2");
	
	if(request.getParameter("country")!=null)
		country = request.getParameter("country");

	if(request.getParameter("first_name")!=null)
	 	first_name = request.getParameter("first_name");

	if(request.getParameter("last_name")!=null)
	 	last_name = request.getParameter("last_name");

	if(request.getParameter("email")!=null)
	 	email = request.getParameter("email");
	
	if(request.getParameter("phone")!=null)
	 	phone = request.getParameter("phone");

	if(request.getParameter("address")!=null)
	 	address = request.getParameter("address");

	if(request.getParameter("city")!=null)
	 	city = request.getParameter("city");

	if(request.getParameter("state")!=null)
		 state = request.getParameter("state");

	if(request.getParameter("zipcode")!=null)
		 zipcode = request.getParameter("zipcode");

%>

<%@include file='templates/header.jsp'%>


<script language="JavaScript" src="js/gen_validatorv31.js" type="text/javascript"></script>


<script type="text/javascript">
	var progress = 0;

	function calculateProgress()
	{
		var form = document.getElementsByTagName("input");
		var count =0;
		
		for(i =0;i<form.length;i++)
		{
		if(form[i].value.length>0)
			{
			count = count +1;
			}
		}
		progress = count/form.length*100;
		progress = parseInt(progress);

		document.getElementById("progress_value").innerHTML = progress +"%";

		document.getElementById("progress_fill").style.width = progress +"%";
		}
	
</script> 
	<h3>Create your Awesome Account</h3> <br /> 


<div style = "float:right;width: 250px; height: 200px;"> 
	<h3>Progress </h3>
	<div id="progress" style="height:15px; border:1px solid #cecece; margin-top:5px" >
		<div id="progress_fill" style="background:#a3d252; width:0px"> &nbsp;  </div>
	</div>
	<div id="progress_value" style="color:#676767"> 0% </div>
</div>

<div>
	<form name = "signup" action ="process.jsp" method="post">
	<div id='signup_errorloc' style='color:#bf0f28;'>
    	<%=errorString %> 
	</div>
<div>
	<h3>1. Select a Username and Password</h3>
	</div>
		<table>
			<tr>
				<td>Username: </td>
				<td><input type="text" name = "username"  value="<%=username%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>Create a Password: </td>
				<td><input type="password" name = "password1"  onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>Re-type Password: </td>
				<td><input type="password" name = "password2"  onchange ="calculateProgress()" /></td>
			</tr>
			
		</table>
	<br /> <br />
	
<div> 
	<h3>2. Tell us about yourself</h3></div>
	
		<table>
				<td>First Name: </td>
				<td><input type="text" name = "first_name"  value="<%=first_name%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>MI: </td>
				<td><input type="text" name = "MI" size = "1" value="<%=last_name%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>Last Name: </td>
				<td><input type="text" name = "last_name" value="<%=last_name%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>Email: </td>
				<td><input type="text" name = "email" value="<%=email%>" onchange ="calculateProgress()" /></td>
			</tr>	
			<tr>
				<td>Phone: </td>
				<td><input type="text" name = "phone" value="<%=phone%>" onchange ="calculateProgress()" /></td>
			</tr>			
			<tr>
				<td>Country: </td>
				<td>
					<select style="width:147px;" name="country" >
          
          <option value="US" selected>United States</option>
<option value="GB">United Kingdom</option>
<option value="CA">Canada</option>
<option value="AU">Australia</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>

<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua And Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>

<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>

<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia And Herzegowina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>

<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>

<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>

<option value="CD">Congo, The Democratic Republic Of The</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Cote D'Ivoire</option>
<option value="HR">Croatia (Local Name: Hrvatska)</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>

<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TP">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>

<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands (Malvinas)</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="FX">France, Metropolitan</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>

<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>

<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GG">Guernsey</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>

<option value="HM">Heard And Mc Donald Islands</option>
<option value="VA">Holy See (Vatican City State)</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IQ">Iraq</option>

<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JE">Jersey</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>

<option value="KI">Kiribati</option>
<option value="KR">Korea, Republic Of</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Lao People'S Democratic Republic</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>

<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia, Former Yugoslav Republic Of</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>

<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia, Federated States Of</option>

<option value="MD">Moldova, Republic Of</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="ME">Montenegro</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>

<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>

<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>

<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>

<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="KN">Saint Kitts And Nevis</option>
<option value="LC">Saint Lucia</option>
<option value="VC">Saint Vincent And The Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome And Principe</option>

<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="RS">Serbia</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia (Slovak Republic)</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>

<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia, South Sandwich Islands</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SH">St. Helena</option>
<option value="PM">St. Pierre And Miquelon</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard And Jan Mayen Islands</option>

<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania, United Republic Of</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>

<option value="TO">Tonga</option>
<option value="TT">Trinidad And Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks And Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>

<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VE">Venezuela</option>
<option value="VN">Viet Nam</option>

<option value="VG">Virgin Islands (British)</option>
<option value="VI">Virgin Islands (U.S.)</option>
<option value="WF">Wallis And Futuna Islands</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>

          </select>   </td>
			</tr>
			<tr>
				<td>Address: </td>
				<td><input type="text" name = "address" value="<%=address%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>City: </td>
				<td><input type="text" name = "city" value="<%=city%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
				<td>State: </td>
				<td><select style="width:146px;" name="state" value="<%=state%>" id="STATE" onmousewheel="return false;" selected="">
          <option value="">Click to Select (if applicable)</option>
          <OPTION VALUE="AL">Alabama</OPTION>
<OPTION VALUE="AK">Alaska</OPTION>
<OPTION VALUE="AS">American Samoa</OPTION>
<OPTION VALUE="AZ">Arizona</OPTION>
<OPTION VALUE="AR">Arkansas</OPTION>
<OPTION VALUE="AE">Armed Forces - Europe</OPTION>

<OPTION VALUE="AP">Armed Forces - Pacific</OPTION>
<OPTION VALUE="AA">Armed Forces - USA/Canada</OPTION>
<OPTION VALUE="CA">California</OPTION>
<OPTION VALUE="CO">Colorado</OPTION>
<OPTION VALUE="CT">Connecticut</OPTION>
<OPTION VALUE="DE">Delaware</OPTION>
<OPTION VALUE="DC">District of Columbia</OPTION>
<OPTION VALUE="FM">Federated States of Micronesia</OPTION>
<OPTION VALUE="FL">Florida</OPTION>

<OPTION VALUE="GA">Georgia</OPTION>
<OPTION VALUE="GU">Guam</OPTION>
<OPTION VALUE="HI">Hawaii</OPTION>
<OPTION VALUE="ID">Idaho</OPTION>
<OPTION VALUE="IL">Illinois</OPTION>
<OPTION VALUE="IN">Indiana</OPTION>
<OPTION VALUE="IA">Iowa</OPTION>
<OPTION VALUE="KS">Kansas</OPTION>
<OPTION VALUE="KY">Kentucky</OPTION>

<OPTION VALUE="LA">Louisiana</OPTION>
<OPTION VALUE="ME">Maine</OPTION>
<OPTION VALUE="MH">Marshall Islands</OPTION>
<OPTION VALUE="MD">Maryland</OPTION>
<OPTION VALUE="MA">Massachusetts</OPTION>
<OPTION VALUE="MI">Michigan</OPTION>
<OPTION VALUE="MN">Minnesota</OPTION>
<OPTION VALUE="MS">Mississippi</OPTION>
<OPTION VALUE="MO">Missouri</OPTION>

<OPTION VALUE="MT">Montana</OPTION>
<OPTION VALUE="NE">Nebraska</OPTION>
<OPTION VALUE="NV">Nevada</OPTION>
<OPTION VALUE="NH">New Hampshire</OPTION>
<OPTION VALUE="NJ">New Jersey</OPTION>
<OPTION VALUE="NM">New Mexico</OPTION>
<OPTION VALUE="NY">New York</OPTION>
<OPTION VALUE="NC">North Carolina</OPTION>
<OPTION VALUE="ND">North Dakota</OPTION>

<OPTION VALUE="OH">Ohio</OPTION>
<OPTION VALUE="OK">Oklahoma</OPTION>
<OPTION VALUE="OR">Oregon</OPTION>
<OPTION VALUE="PA">Pennsylvania</OPTION>
<OPTION VALUE="PR">Puerto Rico</OPTION>
<OPTION VALUE="RI">Rhode Island</OPTION>
<OPTION VALUE="SC">South Carolina</OPTION>
<OPTION VALUE="SD">South Dakota</OPTION>
<OPTION VALUE="TN">Tennessee</OPTION>

<OPTION VALUE="TX">Texas</OPTION>
<OPTION VALUE="UT">Utah</OPTION>
<OPTION VALUE="VT">Vermont</OPTION>
<OPTION VALUE="VI">Virgin Islands</OPTION>
<OPTION VALUE="VA">Virginia</OPTION>
<OPTION VALUE="WA">Washington</OPTION>
<OPTION VALUE="WV">West Virginia</OPTION>
<OPTION VALUE="WI">Wisconsin</OPTION>
<OPTION VALUE="WY">Wyoming</OPTION>

<OPTION VALUE="AB">Alberta</OPTION>
<OPTION VALUE="BC">British Columbia</OPTION>
<OPTION VALUE="MB">Manitoba</OPTION>
<OPTION VALUE="NB">New Brunswick</OPTION>
<OPTION VALUE="NF">Newfoundland</OPTION>
<OPTION VALUE="MP">Northern Mariana Island	</OPTION>
<OPTION VALUE="NT">Northwest Territories</OPTION>
<OPTION VALUE="NS">Nova Scotia</OPTION>
<OPTION VALUE="ON">Ontario</OPTION>

<OPTION VALUE="PW">Palau Island</OPTION>
<OPTION VALUE="PE">Prince Edward Island</OPTION>
<OPTION VALUE="QC">Quebec</OPTION>
<OPTION VALUE="SK">Saskatchewan</OPTION>
<OPTION VALUE="YT">Yukon Territory</OPTION>
<OPTION VALUE="Australian Capital Territory">Australian Capital Territory</OPTION>
<OPTION VALUE="New South Wales">New South Wales</OPTION>
<OPTION VALUE="Northern Territory">Northern Territory</OPTION>
<OPTION VALUE="Queensland">Queensland</OPTION>

<OPTION VALUE="South Australia">South Australia</OPTION>
<OPTION VALUE="Tasmania">Tasmania</OPTION>
<OPTION VALUE="Victoria">Victoria</OPTION>
<OPTION VALUE="Western Australia">Western Australia</OPTION>

          </select> 
</td>
			</tr>
			<tr>
				<td>ZIP code: </td>
				<td><input type="text" name = "zipcode"  value="<%=zipcode%>" onchange ="calculateProgress()" /></td>
			</tr>
			<tr>
			<td></td><td><input type="submit" name = "Submit"  value="submit" onchange ="calculateProgress()" /></td>
			</tr>
		</table>
		
	</form>
	<br />
</div>

 <script language="JavaScript">
 var frmvalidator  = new Validator("signup");
 frmvalidator.EnableOnPageErrorDisplaySingleBox();
 frmvalidator.EnableMsgsTogether();

 frmvalidator.addValidation("username","req","Please enter your user name");
 
 frmvalidator.addValidation("password1","req","Please enter your Password");
 frmvalidator.addValidation("password2","req","Please enter your Password");
 
 
  frmvalidator.addValidation("first_name","req","Please enter your First Name");
  frmvalidator.addValidation("first_name","maxlen=20",	"Max length for FirstName is 20");
  frmvalidator.addValidation("first_name","alpha_s","First name can contain alphabetic chars only");

  frmvalidator.addValidation("MI","req","Please enter your Middle Initial");

   
  frmvalidator.addValidation("last_name","req","Please enter your Last Name");
  frmvalidator.addValidation("last_name","maxlen=20","For LastName, Max length is 20");
  
  frmvalidator.addValidation("email","maxlen=50");
  frmvalidator.addValidation("email","req", "Email address Required");
  frmvalidator.addValidation("email","email","Please enter a valid email address");

  frmvalidator.addValidation("phone","maxlen=10");
  frmvalidator.addValidation("phone","req", "Phone no is required");
  
  frmvalidator.addValidation("zipcode","maxlen=5");
  frmvalidator.addValidation("zipcode","numeric");
  
  frmvalidator.addValidation("address","maxlen=50"); 
  frmvalidator.addValidation("city","maxlen=50");
  
  frmvalidator.addValidation("state","dontselect=0");
</script>
 
<%@include file='templates/footer.jsp'%>